local skill = fk.CreateSkill {
  name = "lvshi__shensu",
}

Fk:loadTranslationTable{
  ["lvshi__shensu"] = "神速",
  ["#lvshi__shensu_viewas"] = "神速",
  [":lvshi__shensu"] = "当你的一个<a href='main_phase'>主要阶段</a>开始时，你可将一个区域内的所有牌当雷【杀】使用，此【杀】造成伤害后，你可移动对方场上一张牌至你相同区域。",
  ["#lvshi__shensu-choose"] = "你可以将一个区域内的所有牌当雷【杀】使用",
  ["#lvshi__shensu-damage"] = "神速：你可以移动%src场上一张牌至你相同区域",

  ["$lvshi__shensu1"] = "疾风拂面，日隔千里！",
  ["$lvshi__shensu2"] = "大步流星，不知所由！",
  ["$lvshi__shensu3"] = "奔轶绝尘，不留踪影！",
  ["$lvshi__shensu4"] = "健步如飞，破敌不备！",
}

skill:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skill.name) and target == player then
      local phase_table = {Player.Judge, Player.Draw, Player.Play, Player.Discard}
      return table.contains(phase_table, player.phase)
    end 
  end,
  on_cost = function (self, event, target, player, data)
    local _, dat = player.room:askToUseActiveSkill(player, {
      skill_name = "#lvshi__shensu_viewas",
      prompt = "#lvshi__shensu-choose",
      cancelable = true,
    })
    if dat then
      event:setCostData(self, {tos = dat.targets, flag = dat.interaction})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local flag = "h"
    if event:getCostData(self).flag == "$Judge" then
      flag = "j"
    elseif event:getCostData(self).flag == "$Equip" then
      flag = "e"
    end
    room:useVirtualCard("lvs_thunder__slash", player:getCardIds(flag), player, event:getCostData(self).tos, skill.name)
  end,
})

skill:addEffect(fk.Damage, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skill.name) and target == player then
      return data.card and data.card.skillName == skill.name and data.to:canMoveCardsInBoardTo(player)
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = skill.name,
      prompt = "#lvshi__shensu-damage:"..data.to.id
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:askToMoveCardInBoard(player, {
      target_one = data.to,
      target_two = player,
      skill_name = skill.name,
      move_from = data.to,
    })
  end,
})

return skill
